/* TIMER CON COOKIES jquery */

	(function( $ ){
		var Cookie = {
	        set: function(name,value,seconds){
	            if(seconds){
	                d = new Date();
	                d.setTime(d.getTime() + (seconds * 1000));
	                expiry = '; expires=' + d.toGMTString();
	            }else
	                expiry = '';
	            document.cookie = name + "=" + value + expiry + "; path=/";
	        },
	        get: function(name){
	            nameEQ = name + "=";
	            ca = document.cookie.split(';');
	            for(i = 0; i < ca.length; i++){
	                c = ca[i];
	                while(c.charAt(0) == ' ')
	                    c = c.substring(1,c.length);
	                if(c.indexOf(nameEQ) == 0)
	                    return c.substring(nameEQ.length,c.length);
	            }
	            return null
	        },
	        unset: function(name){
	            Cookie.set(name,'',-1);
	        }
		}

		function temporize() {


		}

		$.fn.countDown = function(minutes_left) {
			
			var seconds = Cookie.get("minutes") != null ? Cookie.get("seconds") : 59;
			var minutes = Cookie.get("minutes") != null ? Cookie.get("minutes") : minutes_left - 1;

			if(seconds > 0){
				seconds--;
				Cookie.set("seconds", seconds, (minutes*60));
			}else{
				minutes--;
				seconds = 59;
				Cookie.set("minutes", minutes, (minutes*60));
			}

			if(minutes > 0 || seconds > 0){
				setTimeout("$.fn.countDown.call()", 1000);
			}else{
				this.append(" <?php echo $this->lang->line("txt_time_over") ?>");
			}

			this.html((minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds));

		};
	})( jQuery );
	
	$(document).ready(function(){
		$("div.timer").countDown(<?php echo $evaluation["max_time"]; ?>);
	});
